#ifndef TEACHMODEL_H
#define TEACHMODEL_H

#include <QAbstractListModel>
#include <QObject>
#include "databasemanager.h"

class TeachModel : public QAbstractListModel
{
    Q_OBJECT
public:
    enum Roles{
        NameRole = Qt::UserRole+1,
    };
    explicit TeachModel(QObject *parent = nullptr);
public:
    void resetData();
    QString getTeachJson(int nIndex);
    QString teachDataToJson(QVector<TeachData> teachData);
    int getCountTime(int nIndex);
    QVector<TeachData> getTeachData(int nIndex);
    int rowCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
    bool insertTeach(const QString teachName, QVector<TeachData> vTeachData,QString &strErr);
    bool deleteTeach(int nIndex);
    bool editTeach(int nIndex,const QString teachName,const QString teachOldName,QVector<TeachData> teachJson,QString &strErr);
private:
    QList<TeachInfo> teachList;
};

#endif // TEACHMODEL_H
